using System.IO;
using NFreeMarker.Template;

namespace NFreeMarker.Core
{
    /**
     * This exception is thrown when a &lt;stop&gt;
     * directive is encountered. 
     */

    public class StopException : TemplateException
    {
        internal StopException(Environment env)
            : base(env)
        {
        }

        internal StopException(Environment env, string s)
            : base(s, env)
        {
        }

        public override void PrintStackTrace(TextWriter pw)
        {
            string msg = Message;
            pw.Write("Encountered stop instruction");
            if (!string.IsNullOrEmpty(msg))
            {
                pw.WriteLine("\nCause given: " + msg);
            }
            else
            {
                pw.WriteLine();
            }
            base.PrintStackTrace(pw);
        }
    }
}